#ifndef _CONSUMERIMPL_H_
#define _CONSUMERIMPL_H_

#include "stdafx.h"
#include "auth.hpp"

class CConsumerImpl :	public  IConsumer,
						public  IOperationEvent,
						public	CChannel,
						public	CUnknownImp
		
{
public:
	CConsumerImpl(void);
	virtual ~CConsumerImpl(void);

	BEGIN_STDCOM_MAP
		STDCOM_INTERFACE_ENTRY_UNKNOWN_(IConsumer)
		STDCOM_INTERFACE_ENTRY(IOperationEvent)
		STDCOM_INTERFACE_ENTRY(IConsumer)
	END_STDCOM_MAP

public:
	//IConsumer
	std_method(SetId)(unsigned int id);
	std_method(Bind)(LPCSTR addr, int len);
	std_method(Close)();
	std_method(Recv)(IBase* pBase);

	//IOperationEvent
	std_method(OnComplete)(IBase *pOperation, event_id event, ULONG error_code);
private:
	std_method(OnConnected)(IBase *pIBase);
	std_method(OnSendSeqed)(IBase *pIBase);
	std_method(OnRecvSeqAcked)(IBase *pIBase);
	std_method(OnSendAcked)(IBase *pIBase);
	std_method(OnRecvHeaded)(IBase *pIBase);
	std_method(OnRecved)(IBase *pIBase);
private:
	CSemHandle		m_sem;
	unsigned int	m_id;
	BusProtocol		m_bus;
};

#endif
